﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;

namespace AnyOffice.general.meeting
{
    public partial class meeting_detail : ModulePage
    {


        protected void Page_Load(object sender, EventArgs e)
        {
            int meetingId = (Request.QueryString["meeting_id"] != null) ? int.Parse(Request.QueryString["meeting_id"]) : 0;
            DataTable table = new MeetingDao().SelectByMeetingId(base.Conn, meetingId);
            if (table.Rows.Count == 0)
            {
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowErrorClose("无未找到相应记录！");
            }
            else
            {
                this.litMeetingId.Text = (table.Rows[0]["MeetingId"] != DBNull.Value) ? table.Rows[0]["MeetingId"].ToString() : "";
                this.litName.Text = (table.Rows[0]["Name"] != DBNull.Value) ? table.Rows[0]["Name"].ToString() : "";
                this.litTopic.Text = (table.Rows[0]["Topic"] != DBNull.Value) ? table.Rows[0]["Topic"].ToString() : "";
                string str = (table.Rows[0]["Description"] != DBNull.Value) ? table.Rows[0]["Description"].ToString() : "";
                str = str.Replace("\r\n", "<br>");
                this.litDescription.Text = str;
                this.litProposerName.Text = (table.Rows[0]["ProposerName"] != DBNull.Value) ? table.Rows[0]["ProposerName"].ToString() : "";
                this.litRequestTime.Text = (table.Rows[0]["RequestTime"] != DBNull.Value) ? table.Rows[0]["RequestTime"].ToString() : "";
                this.litAttendeeName.Text = (table.Rows[0]["AttendeeName"] != DBNull.Value) ? table.Rows[0]["AttendeeName"].ToString() : "";
                this.litGuest.Text = (table.Rows[0]["Guest"] != DBNull.Value) ? table.Rows[0]["Guest"].ToString() : "";
                this.litStartTime.Text = (table.Rows[0]["StartTime"] != DBNull.Value) ? table.Rows[0]["StartTime"].ToString() : "";
                this.litEndTime.Text = (table.Rows[0]["EndTime"] != DBNull.Value) ? table.Rows[0]["EndTime"].ToString() : "";
                this.litRoomName.Text = (table.Rows[0]["RoomName"] != DBNull.Value) ? table.Rows[0]["RoomName"].ToString() : "";
                string str2 = table.Rows[0]["Status"].ToString();
                if (str2 != null)
                {
                    if (!(str2 == "0"))
                    {
                        if (!(str2 == "1"))
                        {
                            if (str2 == "2")
                            {
                                this.litStatus.Text = "未批准";
                            }
                            return;
                        }
                    }
                    else
                    {
                        this.litStatus.Text = "待批";
                        return;
                    }
                    if (Convert.ToDateTime(table.Rows[0]["StartTime"].ToString()) > DateTime.Now)
                    {
                        this.litStatus.Text = "未开始";
                    }
                    else if ((Convert.ToDateTime(table.Rows[0]["StartTime"].ToString()) < DateTime.Now) && (Convert.ToDateTime(table.Rows[0]["EndTime"].ToString()) > DateTime.Now))
                    {
                        this.litStatus.Text = "进行中";
                    }
                    else if (Convert.ToDateTime(table.Rows[0]["EndTime"].ToString()) > DateTime.Now)
                    {
                        this.litStatus.Text = "已结束";
                    }
                    else
                    {
                        this.litStatus.Text = "已准";
                    }
                }
            }
        } 

    }
}
